package com.lzm.ydpt.utils;

import android.app.Activity;

import com.byt.framlib.commonwidget.finder.addresswheelfinder.picker.SinglePicker;
import com.byt.framlib.commonwidget.finder.addresswheelfinder.widget.WheelView;
import com.lzm.ydpt.BaseColor;

import java.util.ArrayList;

public class SelectUtil {

    /**
     * 单项选择器
     */
    public static void showDefaultPicker(Activity activity, ArrayList<String> dayData, String title, SinglePicker.OnItemPickListener<String> listener, int defaultIndex) {
        final SinglePicker<String> mPicker = new SinglePicker(activity, dayData);
        initDefaultPicker(mPicker, title, listener, true, defaultIndex);
    }

    private static void initDefaultPicker(SinglePicker<String> mPicker, String title, SinglePicker.OnItemPickListener<String> listener, boolean isShow, int defaultIndex) {
        mPicker.setDividerVisible(true);
        mPicker.setCycleDisable(true);
        mPicker.setSelectedIndex(defaultIndex);
        mPicker.setTitleText(title);
        mPicker.setTitleTextColor(BaseColor.color_main);
        mPicker.setTextSize(16);
        mPicker.setContentPadding(15, 10);
        mPicker.setTextColor(BaseColor.color_main);
        mPicker.setTopLineColor(BaseColor.color_333333);
        mPicker.setSubmitTextColor(BaseColor.color_333333);
        mPicker.setCancelTextColor(BaseColor.color_666666);
        mPicker.setDividerColor(BaseColor.color_e9e9e9);
        mPicker.setDividerConfig(new WheelView.DividerConfig().setRatio(0.1f));
        mPicker.setOnItemPickListener(listener);
        if (isShow) {
            mPicker.show();
        }
    }
}
